package interview_questions;

import java.util.Scanner;

public class Main1_5 {
	public static int compressSize(String str) {
		if (str.isEmpty() || str == null) return 0;
		int count = 1;
		for (int i = 1; i < str.length(); i++)
			if (str.charAt(i) != str.charAt(i-1))
				count++;
		return count * 2;
	}
	
	public static String compressString(String str) {
		int compressSize = compressSize(str);
		if (compressSize >= str.length()) return str;
		StringBuffer newStr = new StringBuffer();
		newStr.append(str.charAt(0));
		int curCount = 1;
		for (int i = 1; i < str.length(); i++) {
			if (str.charAt(i) == str.charAt(i-1))
				curCount++;
			else {
				newStr.append(curCount);
				newStr.append(str.charAt(i));
				curCount = 1;
			}
		}
		newStr.append(curCount);
		return newStr.toString();
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String str = in.next();
		String s = compressString(str);
		System.out.println("After compressed: " + s);
		in.close();
	}

}